package SortAlgorithmPractice;

import java.util.Arrays;

public class SelectionSort {
    public static void main(String[] args) {
        int[] arr = {3,1,5,6,9,7,8,10};
        System.out.printf("Sort before : %s\n", Arrays.toString(arr));
        SelectionSort(arr);
        System.out.printf("Sort after : %s\n", Arrays.toString(arr));
    }

    public static void SelectionSort(int[] arr) {
        for (int i = 0; i < arr.length - 1; i++) {
            int index = i;
            for (int j = i + 1; j < arr.length; j++) {
                if(arr[i] > arr[j]){
                     index = j;
                }
            }
            BubbleSort.swap(arr, i, index);
        }
    }
}
